<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript">
		function reset_clerk_info(){
		  $('#address').val('');
		  $('#telephone').val('');
		  $('#postcode').val('');
		  $('#customerno').val('');
		  $('#name').val('');
		  $('#identifyno').val('');
		}
        function on_dept_select(node){
          $('#deptno').val(node.id);
          $('#deptno_val').val(node.id);
          $('#identifyno').focus();
        }
        function on_panel_close(){
          $("#sel_customer_dept_pane").panel("destroy");
        }
    	$(document).ready(function(){
    		set_input_keydown_event();
    		$('#sex').combobox();
    		combobox_keypress('#sex','#address');
			$('#sel_customer_dept_pane').panel();
    		$('#depttree').tree({url:'queryDeptTree.action',onClick:on_dept_select,
    			onLoadError: function(){alert('系统错误，服务器可能已关闭！')}});
     		$('#add_customer_panel').panel({onClose:on_panel_close});
    		
     		$('#save').click(function (){
     		  $('#sex_val').val($('#sex').combobox('getValue'));
    		  $('#add_customer_form').form('submit', {
    		    url: 'addCustomer.action',
    		    error:function(message){
    		    	alert('提交数据错误，服务器可能已关闭！系统返回:'+message);
    		  	},
    		    success:function(data){
    		      var a = eval('(' + data + ')');
    		      $.messager.alert('增加客户', a.message, 'info',
    		      	function(){$('#identifyno').focus();});
    		      
    		      if (a.result == '0'){
    		      	reset_clerk_info();
    		      }
    		    }
    		    })
    		});

     		$('#cancel').click(function (){
     			$('#add_customer_panel').panel('close');
    		});
    	});
    </script>
	</head>
	<body>
	
    <div id="add_customer_panel" collapsible="false" fit="true" title="增加客户" resizable="false"
    	minimizable="false" maximizable="false" closable="true" icon="icon-save" class="jquery_panel">
    	<s:form id="add_customer_form" action="addCustomer" theme="simple" cssStyle="margin:0px,0px">
    		<table height="94%">
    			<tr style="vertical-align: top">
    				<td width="280px"><div id="sel_customer_dept_pane" collapsible="false" fit="true" 
    					title="选择机构" resizable="false" collapsible="false" minimizable="false" 
    					maximizable="false" noheader="false" closable="false"
    					style="margin:0px;padding:0px;overflow-y:scroll">
    					<ul id="depttree"></ul></div></td>
    				<td>
			    		<table style="margin:20px,40px;">
    						<tr height="28px">
			    				<td><s:label value="所属机构：" for="deptno"></s:label></td>
    							<td><input id="deptno" style="width:150px"
			    					class="text_field_css" disabled="disabled"></input>
    								<label style="width:4px"></label>
    								<label style="color:red">*</label><label>请选择</label>
    								<s:hidden id="deptno_val" name="deptno"/></td>
			    			</tr>
			    			<tr height="28px">
    							<td><s:label value="身份证号：" for="identifyno"></s:label></td>
			    				<td><input id="identifyno" name="identifyno" 
    								maxlength=<s:property value="%{getText('IDENTIFYNO_LEN')}"/>  
    								style="width:150px" class="text_field_css"></input>
    								<label style="width:4px"></label>
			    					<label style="color:red">*</label>
			    					<label>必输项</label></td>
			    			</tr>
    						<tr height="28px">
			    				<td><s:label value="姓名：" for="name"></s:label></td>
    							<td><input id="name" name="name" 
    								maxlength=<s:property value="%{getText('NAME_LEN')}"/>  
			    					style="width:150px" class="text_field_css"></input>
			    					<label style="width:4px"></label>
			    					<label style="color:red">*</label>
			    					<label>必输项</label></td>
    						</tr>
			    			<tr height="28px">
    							<td><s:label value="客户号：" for="customerno"></s:label></td>
			    				<td><input id="customerno" name="customerno" 
    								maxlength=<s:property value="%{getText('CUSTOMERNO_LEN')}"/>  
    								style="width:150px" class="text_field_css"></input>
    								<label style="width:4px"></label>
			    					<label style="color:red">*</label>
			    					<label>必输项</label></td>
			    			</tr>
			    			<tr height="28px">
    							<td><s:label value="性别：" for="sex"></s:label></td>
			    				<td><select id="sex" editable="false"
    								style="width:200px" panelHeight="auto">
    								<option value="1">男</option><option value="2">女</option>
    								</select><s:hidden id="sex_val" name="sex"/></td>
			    			</tr>
    						<tr height="28px">
			    				<td><s:label value="住址：" for="address"></s:label></td>
    							<td><input id="address" name="address" 
    								maxlength=<s:property value="%{getText('ADDRESS_LEN')}"/>  
			    					style="width:250px" class="text_field_css"></input></td>
    						</tr>
    						<tr height="28px">
			    				<td><s:label value="电话：" for="telephone"></s:label></td>
    							<td><input id="telephone" name="telephone" 
    								maxlength=<s:property value="%{getText('TELEPHONE_LEN')}"/>  
			    					style="width:200px" class="text_field_css"></input></td>
    						</tr>
    						<tr height="28px">
			    				<td><s:label value="邮编：" for="postcode"></s:label></td>
    							<td><input id="postcode" name="postcode" 
    								maxlength=<s:property value="%{getText('POSTCODE_LEN')}"/>  
			    					style="width:200px" class="text_field_css"></input></td>
    						</tr>
    						<tr height="35px">
			    				<td colspan="2" align="center">
            						<button id="save" class="buttons_css" style="width:70px">
            							<label style="70px" class="save_css">保存</label></button>
            						<label style="width:20px"></label>
            						<button id="cancel" class="buttons_css" style="width:70px">
            							<label style="70px" class="cancel_css">返回</label></button>
    							</td>
			    			</tr>
    					</table>
    				</td>
    			</tr>
    		</table>
    	</s:form>
    </div>
    </body>
</html>